package proxy.staticProxy;

/**
 * @ClassName Proxy
 * @Author Alex2
 * @Date 2025/3/19 15:29
 **/

interface Rent {
    void rent();
}

class Landlord implements Rent {
    @Override
    public void rent() {
        System.out.println("房东出租房子");
    }
}

class Proxy implements Rent {
    private final Landlord landlord;

    public Proxy(Landlord landlord) {
        this.landlord = landlord;
    }

    // 代理帮房东租房子
    @Override
    public void rent() {
        System.out.println("房东展示房子");
        landlord.rent();
        System.out.println("房东同意出租");
    }

    public void seeHouse() {
        System.out.println("中介带你看房子");
    }

    public void signContact() {
        System.out.println("中介签合同");
    }
}

public class Consumer {
    public static void main(String[] args) {
        Landlord landlord = new Landlord();
        Proxy proxy = new Proxy(landlord);  //代理帮房东租房子
        proxy.seeHouse();                   //代理的附属操作
        proxy.rent();
        proxy.signContact();                //代理的附属操作
    }
}